<include file='./header' />
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<script type="text/javascript" src="__ROOT__/js/jquery.SuperSlide.js"></script>
<script type="text/javascript">
    var score={$score};
    //alert(score);
    var arrPer = new Array();
    var arrRecommendPer = new Array();

    $(document).ready(function() 
    {
	    getRecommendPer();
        
		
    });

    function getRecommend(v)
    {
        $(function() 
        {
           $.ajax({  
                    type: "post",  
                    url: "__URL__/getRecommend",  
                    dataType: 'json',
                    data: {score:v},
                    beforeSend: function(XMLHttpRequest){   
                    },  
                    error:function(){
                        //alert('error');
                    },
                    async : true,
                    success: function(json)
                    {
                        //alert('success!');
                        if(json.status == 1){
							arrProductList = json.data;
							showProductList();

                        } else
                        {
                            alert('wrong!');
                        }
                    } 
                })
        })
        
    }
     function getGroupHisdata(xj,zj,gp,ll,type){
        $.ajax({  
                    type: "post",  
                    url: "__URL__/getGroupHisdata",  
                    dataType: 'json',
                    data: {'xianjin':xj,'zhaijuan':zj,'gupiao':gp,'linglei':ll},
                    beforeSend: function(XMLHttpRequest){   
                    },  
                    error:function(){
                        alert('error');
                    },
                    async : false,
                    success: function(json)
                    {
                        if(json.status == 1){
                            var data = eval("("+json.data+")");
                            $("#rqzzdsy").text(data['qzzdsy'] +"%");
                            $("#rsyl").text(data['syl']+"%");
                            $("#tdfx").text(data['syqj']);
                        } else
                        {
                            alert('wrong!');
                        }
                    } 
                })
        
    }
 function getRecommendPer(){
        $.ajax({  
                    type: "post",  
                    url: "__URL__/getRecommendPer",  
                    dataType: 'json',
                    data: {'score':score},
                    beforeSend: function(XMLHttpRequest){   
                    },  
                    error:function(){
                        //alert('error');
                    },
                    async : true,
                    success: function(json)
                    {
                        if(json.status == 1){
                            arrRecommendPer['xianjin'] = parseFloat(json.data['xianjin']['percent']);
                            arrRecommendPer['zhaiquan'] = parseFloat(json.data['zhaiquan']['percent']);
                            arrRecommendPer['gupiao'] = parseFloat(json.data['gupiao']['percent']);
                            arrRecommendPer['linglei'] = parseFloat(json.data['linglei']['percent']);
                            showpie2(arrRecommendPer['xianjin'],arrRecommendPer['zhaiquan'],arrRecommendPer['gupiao'],arrRecommendPer['linglei']);
							getRecommend(score);
							getGroupHisdata(arrRecommendPer['xianjin'],arrRecommendPer['zhaiquan'],arrRecommendPer['gupiao'],arrRecommendPer['linglei'],'reco');
                        } else
                        {
                            alert('wrong!');
                        }
                    } 
                })
    }
    
            
//饼状图2
 function showpie2(cashValue,bondValue,stockValue,otherValue){
      $('#pie2').highcharts({
            chart: {
				animation:true
            },
            title: {
                text: '建议',
                style: { "color": "#ff6c60", "fontSize": "16px" ,"fontFamily":"微软雅黑"}       
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.2f}%</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                            format: '{point.name}: {point.percentage:.2f}%',
                            distance: 5
                    },
                    showInLegend: false,
                    innerSize: '40%'
                },
            },
            legend: {
                        layout: 'horizontal',
                        align: 'center',
                        borderWidth: 0,
                        itemWidth: 190,
                        itemMarginTop: 3,
                        width:380,
                        itemStyle : { 'fontWeight' : 'normal' },
                        floating: false,                
                        labelFormatter: function() {
                            return this.name + "：￥"+Highcharts.numberFormat(this.y)+"["+Highcharts.numberFormat(this.percentage)+"%]";
                        }
                    },
            series: [{
                type: 'pie',
                name: '占投资比例',
                data: [
                    {name: '现金', y:cashValue,color: '#ff6c60' },
                    {name: '债券', y: bondValue,color:'#fcb322' },
                    {name: '股票', y: stockValue,color: '#a9d86e' },
                    {name: '另类投资', y: otherValue,color:'#58c9f3'}
					/*{name: '现金', y:1000,color: '#ff6c60' },
                    {name: '债券', y:200,color:'#fcb322' },
                    {name: '股票', y:500,color: '#a9d86e' },
                    {name: '另类投资', y:600,color:'#58c9f3'}*/
                ]
            }]
    })
 
 }
function showProductList() 
{
    //生成底部推荐产品列表html,读取变局数组arrProductList和百分比全局数组arrPer
    $("#productlist").html("");//清除列表
    var str = "";
    
    $.each(arrProductList, function(i, val) {
        if(arrRecommendPer[i] != 0)
        {
         str += "<tr>\r\n";
         str += "   <td>"+ val['name'] +"</td>\r\n";
         str += "   <td></td>\r\n";
 
         str += "   <td><span class='percentage-label'>"+ arrRecommendPer[i].toFixed(2) +"%</span><span class='percentage-bar-container'><span class='percentage-bar' style='width:"+ arrRecommendPer[i] +"%;'></span></span></td>\r\n";
         str += "   <td></td>\r\n";
         str += " </tr>\r\n";
                 
            if (val['product'] == null) {
                v2 = 'nothing';
            }else{
                var proCount = val['product'].length;//产品个数，用于占比的均分 
                var str2 = "";
               $.each(val['product'], function(j, val2) { 
                        var per=arrRecommendPer[i]/proCount;                   
                         str2 += " <tr class='sub_tr'>\r\n";
                         str2 += "   <td class='sub'></td>\r\n";
                         str2 += "   <td class='sub'>" + val2['chinameabbr'] + "</td>\r\n";
                         str2 += "   <td>"+ per.toFixed(2) +"%</td>\r\n";
                         str2 += "   <td class='sub'>" + val2['comment'] + "</td>\r\n";
                         str2 += " </tr>\r\n";                         
                })
            str += str2;
            }
        }
        
    });
    $("#productlist").append(str); 
}


 
</script>
</head>
<body>
<!--顶部开始-->
<include file="./top" />
<!--顶部结束-->
<!--左导航开始-->
<include file="./left" />
<!--左导航结束-->

<!--主体开始-->
<div class="main-content">
	<div class="wrapper">
    	<div class="panel score_result">
        	<div class="panel-head">
                资产分析
                <div class="right">
                    <a href="javascript:void(0)" class="btn btn-danger"  data-reveal-id="riskTest"><i class="fa fa-check-square-o"></i>重新做投资风险测试</a>
                    <a href="__GROUP__/Analyse/testResult" class="btn btn-info"><i class="fa fa-bar-chart-o"></i>查看我的答题结果分析</a>
                </div>
           </div>
            <div class="panel-body">
                <div class="tb_con left ydzt" style="width:50%;padding-top:0;">
                	<div class="ydzt" style="padding:0">
                        <p>登记资产后，可分析现状</p>
                        <a href="__ROOT__/Uc/Invest/accountinfo/1" class="btn btn-danger btn-lg"><i class="fa fa-check-square-o"></i>现在就去登记我的资产！</a>
                        <div class="clear"></div>
                        <img src="__ROOT__/images/lr_img.png" />
                    </div>
                </div>
                <div  class="tb_con right" style="width:50%;">
                	<h1 style="text-align:center;font-size:16px;line-height:40px;">您属于<span class="label label-primary ">{$typeName}</span> 客户，建议：</h1>
                	<div id="pie2" style="width:100%;height:400px;text-align:center">
						<img src="__ROOT__/images/loadingPie.gif" style="margin-top:100px;" />
					</div>
                	<table class="table zcfx" style="width:80%;margin:auto">

                	    <tr>
                            <td>一年平均收益：</td>
                            <td id="rsyl" class="text-danger"></td>
                        </tr>
                        <tr>
                            <td>一年收益区间：</td>
                            <td id='tdfx' class="text-danger"></td>
                        </tr>
                        <tr>
                            <td colspan="2">从5年投资期限来看，95%的概率您的收益会落在此区间。短期投资收益可能明显高于或低于此范围。</td>
                        </tr>              	    
                	</table>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <!--产品列表开始-->
        <div class="panel">
        	<div class="panel-head">
                根据您的配置，我们推荐以下产品：
            <!--推荐产品列表-->
            <div class="panel-body score_table">
                <table class="table">
                  <thead>
                      <tr>
                        <th width="10%">资产类别</th>
                        <th width="25%">推荐产品列表</th>
                        <th width="30%">推荐比例</th>
                        <th >推荐理由</th>
                      </tr>
                  </thead>
                  <tbody id="productlist">
                    
                  </tbody>
                </table>
                <div class="blank10"></div>
                <div class="right">

                </div>
                <div class="clear"></div>
            </div>
        </div>
        <!--产品列表结束-->
    </div>
</div>
<!--主体结束-->
<!--底部开始-->
<include file="./foot" />
<!--底部结束-->
<!--弹出层开始-->
<include file="question" />
<!--弹出层结束-->
</body>
</html>